
//***********************************************
//
//      Filename: pp8_5.java
//
//        Author: wwb
//        Mails: 1274860621@qq.com
//        Create: 2018-04-15 13:31:05
// Last Modified: 2018-04-15 13:31:05
//***********************************************
import java.util.Scanner;

public class pp8_5 {
    public static void main(String[] args) {
     Scanner scan = new Scanner(System.in);
     Scanner Line = new Scanner(System.in);
     Scanner pp = new Scanner(System.in);
     double sum1 = 0;/*没有第一个数的求和*/
     double sum = 0;/*输入所有数的求和*/
     double mean = 0;/*均值*/
     double sd = 0;/*方差*/
     double sum2 = 0;/*抛去第一个数，number之和*/
     double number = 0;/*抛去第一个数，输入数字与均值的差的平方*/
     int index =0;/*累加器的作用*/
        double Sum;/*加上第一个数根号加的平方和*/
     String line ;
        int[] numbers = new int[50];
        System.out.println("please enter number" + (index+1) + ": ");
        numbers[index] = scan.nextInt();
        System.out.println("Do you want to begin?");
        line = pp.nextLine();
     while (index>=0&&index<50 && line.equalsIgnoreCase("y"))
     {
         index++;
         System.out.println("please enter number" + (index+1)+": ");
         numbers[index] = scan.nextInt();
         sum1 += numbers[index];
         sum = sum1+numbers[0];
         mean = sum/(index+1);
         number = Math.pow((numbers[index]-mean),2);
         sum2 += number;
         Sum = sum2 + Math.pow(numbers[0]-mean,2);
         sd = Math.sqrt(Sum);
         System.out.println("Do you want to continue?");
         line = Line.nextLine();
     }

     System.out.println("sum: "+ sum + "\ntimes: "+ (index+1)+ "\nmean: " + mean + "\nsd: " + sd);

    }
}

